package model.entity;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "News")
public class News {

	private int newsId;
	private String title;
	private Date dateCreated;
	private String contents;
	private List<Sales> saleses = new ArrayList<Sales>(0);

	public News() {
	}

	public News(int newsId, String title, Date dateCreated, String contents) {
		this.newsId = newsId;
		this.title = title;
		this.dateCreated = dateCreated;
		this.contents = contents;
	}

	public News(int newsId, String title, Date dateCreated, String contents,
			List<Sales> saleses) {
		this.newsId = newsId;
		this.title = title;
		this.dateCreated = dateCreated;
		this.contents = contents;
		this.saleses = saleses;
	}

	@Id
	@GeneratedValue(generator = "News_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "News_ID_Gen", sequenceName = "News_SEQ_ID")
	@Column(name = "NewsID", unique = true, nullable = false)
	public int getNewsId() {
		return this.newsId;
	}

	public void setNewsId(int newsId) {
		this.newsId = newsId;
	}

	@Column(name = "Title", nullable = false)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DateCreated", nullable = false, length = 23)
	public Date getDateCreated() {
		return this.dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	@Column(name = "Contents", nullable = false)
	public String getContents() {
		return this.contents;
	}

	public void setContents(String contents) {
		this.contents = contents;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "news")
	public List<Sales> getSaleses() {
		return this.saleses;
	}

	public void setSaleses(List<Sales> saleses) {
		this.saleses = saleses;
	}

}
